var template_=`<div>
    
        <!--直接引入 <script src="components/find.js"></script> --->
        <query-component  @query="handleQuery"></query-component> 
        <el-button type="info" icon="el-icon-download" @click="exportTable">导出</el-button>
        <el-table :data="tableData" style="width: 100%" height="630" >
            <el-table-column type="index" label="序号"></el-table-column>
            <el-table-column prop="kh" label="考号"></el-table-column>
            <el-table-column prop="school" label="学校"></el-table-column>
            <el-table-column prop="zf" label="总分"></el-table-column>

            <el-table-column label="操作">
                <template #default="{ row }">
                    <el-button type="text" @click="showEditRoleDialog(row)">编辑</el-button>
                    <el-button type="text" @click="deleteRole(row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <!---导入 CustomizePagination : () => import('../components/pagination.js') -->
        <CustomizePagination :page="currentPage" :total=pageTotal :size="pageSize"
              @page-change="handlePageChange" />
</div>`

import pg from '../components/pagination.js'  //第一种方式
export default {
    name:'table_',
    data() {
        return {
            findNr:'',
            tableData: [],
            loading: false,

            pageSize:20,
            currentPage:1,
            pageTotal:0,
            sort:'id',
            order:'asc',

            routerList:[],
        }
    },
    methods: {
        getData(v) {
            if (v=='find')  //点【查询】时，要从第一页开始
                this.pageNum=1

            this.loading=true
            axios.post('controller/tableList.php?lx=list', {    ///GetListData
                nr:this.findNr,
                page:this.currentPage,
                size:this.pageSize,
                sort:this.sort,
                order:this.order,
            }).then((res) => {
                if (res.data.code==200) {
                    this.loading=false
                    this.pageTotal=parseInt(res.data.total)
                    this.tableData=res.data.data
                }
            });
        },
        handlePageChange(val,size){
            this.currentPage=val
            this.pageSize=size
            this.getData()
        },
        sort_change(column, prop, order){
            this.sort=column.prop
            this.order=column.order=="descending"?"DESC":"ASC"
            this.getData()
        },
        handleQuery(keyword) {
            console.log('查询关键字:', keyword);
            this.findNr=keyword
            this.getData()
        },
        exportTable(){
            excelJson=[['姓名', '性别', '学校','身份证']]
            for(const item of this.tableData){
              const temp=[item.xm,item.sex,item.school,item.sfz]
              excelJson.push(temp)
            }
            const sheet=XLSX.utils.aoa_to_sheet(excelJson)
            openDownloadDialog(sheet2blob(sheet), '导出.xlsx')
        },
    },
    mounted(){
        this.getData()
        this.routerList=this.$route.matched
        console.log("--routerList",this.routerList)
    },
    components:{
        CustomizePagination : pg,  //第一种方式
        //CustomizePagination : () => import('../components/pagination.js')  //第二种方式
    },
    template: template_
};
